with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Tasques3 is

  Num_Voltes: Positive;
  Num_Tasques: Positive;
  Total: Natural := 0;

  task type T(Id: Integer; Voltes: Positive);

  task body T is
  begin
    for I in 1..Voltes loop
      Total := Total + 1;
    end loop;
    Put(Id, Width => 0); Put(':'); Put(Total, Width => 0); New_Line;
  end T;

begin
  Put("Quantes voltes? ");
  Get(Num_Voltes);
  Put("Quantes tasques? ");
  Get(Num_Tasques);
  declare
    type PT is access T;
    P: array (1..Num_Tasques) of PT;
  begin
    for Id in 1..Num_Tasques loop
      P(Id) := new T(Id, Num_Voltes);
    end loop;
  end;
  New_Line;
  Put("El total es: "); Put(Total, Width =>0); New_Line;
end Tasques3;
